package com.wg.db.convert;

import cn.hutool.core.util.StrUtil;

import java.util.HashSet;
import java.util.Set;

/**
 * @author 少爷123
 */
public class LongSetConvert implements IConvert<Set<Long>> {
    @Override
    public Set<Long> parseObject(Object obj) {
        if (!(obj instanceof String)) {
            return new HashSet<>();
        }

        String str = (String) obj;
        if (StrUtil.isEmpty(str)) {
            return new HashSet<>();
        }

        Set<Long> longSet = new HashSet<>(32);
        long[] array = StrUtil.splitToLong(str, ",");
        for (long value : array) {
            longSet.add(value);
        }
        return longSet;
    }
}
